<template>
  <el-container>
    <el-header id="manageHeader" height="80px" style="background-color:slategray">
      <!-- 搜索表单 -->
      <el-form :inline="true" :model="searchBase" class="demo-form-inline" style="margin-top: 1.5%;">
        <el-form-item label="教师号">
          <el-input v-model="searchBase.teacherid" placeholder="教师号" style="width: 160px;">
          </el-input>
        </el-form-item>
        <el-form-item label="姓名">
          <el-input v-model="searchBase.teacherName" placeholder="姓名" style="width: 160px;">
          </el-input>
        </el-form-item>
        <el-form-item label="目前状态">
          <el-select v-model="value" style="width:90px" placeholder="请选择">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
        <!-- 导出数据为Excel-->
        <el-form-item>


          <download-excel class="export-excel-wrapper" :data="teacherinfo" :fields="json_fields" name="教师基本信息.xls">
            <!-- 上面可以自定义自己的样式，还可以引用其他组件button -->
            <el-button type="primary">导出EXCEL</el-button>
          </download-excel>

        </el-form-item>
      </el-form>
    </el-header>
    <el-main>

      <!--教师表格-->
      <template>
        <el-table :data="teacherinfo" style="width: 100%" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55">
          </el-table-column>

          <el-table-column prop="teacherid" label="教师号" align="center" width="80px">
          </el-table-column>

          <el-table-column prop="teacherName" label="姓名" align="center" width="80px">
          </el-table-column>
          <el-table-column prop="sex" label="性别" align="center" width="60px">
          </el-table-column>
          <el-table-column prop="title" label="职称" align="center" width="100px">
          </el-table-column>
          <el-table-column prop="education" label="学位" align="center" width="80px">
          </el-table-column>
          <el-table-column prop="tel" label="手机号" align="center" width="130px">
          </el-table-column>
          <el-table-column prop="mail" label="邮箱" align="center" width="180px">
          </el-table-column>
          <el-table-column align="center" label="操作">
            <template slot-scope="scope">
              <el-button type="primary" @click="showUpdate(scope.row)">修改</el-button>
              <el-button type="danger" @click="deleteById(scope.row)">删除</el-button>
              <el-button type="success" @click="showTeacherDetail(scope.row)">详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>

      <!-- 修改:teacherUpdate -->
      <el-dialog title="教师基本信息" :visible.sync="dialogUpdate" width="50%" :close-on-click-modal="false">
        <el-form :model="teacherUpdate" :rules="changeTeacherRules" label-width="100px" :inline="true">
          <el-form-item label="姓名" prop="teacherName">
            <el-input v-model="teacherUpdate.teacherName" style="width:80%" clearable></el-input>
          </el-form-item>
          <el-form-item label="性别" prop="sex">
            <el-select v-model="teacherUpdate.sex" placeholder="请选择性别">
              <el-option label="男" value="男"></el-option>
              <el-option label="女" value="女"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="身份证件号" prop="numberId">
            <el-input v-model="teacherUpdate.numberID" clearable style="width:80%" @blur="changeBirth"></el-input>
          </el-form-item>
          <el-form-item label="民族" required prop="nation">
            <el-select v-model="teacherUpdate.nation" filterable placeholder="请选择民族">
              <el-option v-for="item in nationOptions" :key="item.label" :label="item.label" :value="item.label">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="出生日期" required>
            <el-col :span="11">
              <el-form-item>
                <el-date-picker type="date" placeholder="选择日期" v-model="teacherUpdate.birth" style="width: 200px;"
                  value-format=“yyyy-MM-dd”>
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-form-item>

          <el-form-item label="籍贯" prop="place">
            <el-input v-model="teacherUpdate.place" clearable style="width:200px"></el-input>
          </el-form-item>
          <el-form-item label="政治面貌" prop="polstatus">
            <el-input v-model="teacherUpdate.polstatus" clearable style="width:200px"></el-input>
          </el-form-item>
          <el-form-item label="婚姻状况" prop="marriage">
            <el-select v-model="teacherUpdate.marriage" placeholder="请填写婚姻准状况">
              <el-option label="已婚" value="已婚"></el-option>
              <el-option label="未婚" value="未婚"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="入职时间" required>
            <el-col :span="11">
              <el-form-item>
                <el-date-picker type="date" placeholder="选择日期" v-model="teacherUpdate.entryTime" style="width: 200px;"
                  value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-form-item>

          <el-form-item label="职称">
            <el-select v-model="teacherUpdate.title" placeholder="请填写职称">
              <el-option label="讲师" value="讲师"></el-option>
              <el-option label="副教授" value="副教授"></el-option>
              <el-option label="教授" value="教授"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="研究生导师">
            <el-switch v-model="teacherUpdate.tutor" active-value="是" inactive-value="否" style="width:150px">
            </el-switch>
          </el-form-item>
          <el-form-item label="电话">
            <el-input v-model="teacherUpdate.tel" clearable style="width:250px"></el-input>
          </el-form-item>
          <el-form-item label="电子邮箱">
            <el-input v-model="teacherUpdate.mail" clearable style="width:250px"></el-input>
          </el-form-item>
          <el-form-item label="人员状态">
            <el-select v-model="teacherUpdate.status" placeholder="请填写人员状态">

              <el-option label="在岗人员" value="在岗"></el-option>
              <el-option label="不在岗人员" value="不在岗"></el-option>

            </el-select>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="teacherUpdate.pwd" clearable style="width:200px"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="saveTeacherDetail">保存</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <!-- 详情：绑定teacherBaseDetail -->
      <el-dialog title="教师基本信息" :visible.sync=" dialogDetail" width="90%" :close-on-click-modal="false">

        <!-- 卡片式查看教师信息 -->
        <el-tabs type="card" tab-position="top" height="550" ref="watchTeacherDetail">
          <el-tab-pane label="教师基本信息" height="250">
            <!-- div里存放基本信息 -->
            <div id="teacherDetailList" ref="teacherDetailList">
              <el-descriptions class="margin-top" title="教师基本信息" :column="3" border>

                <el-descriptions-item label="教师号">{{ teacherBaseDetail.teacherid }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label">
                    <i class="el-icon-user"></i> 姓名 </template>
                  {{teacherBaseDetail.teacherName}}
                </el-descriptions-item>
                <el-descriptions-item label="性别">{{ teacherBaseDetail.sex }}
                </el-descriptions-item>
                <el-descriptions-item label="出生日期">{{ teacherBaseDetail.birth }}
                </el-descriptions-item>
                <el-descriptions-item label="民族">{{ teacherBaseDetail.nation }}
                </el-descriptions-item>
                <el-descriptions-item label="身份证件号">{{ teacherBaseDetail.numberID }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label">
                    <i class="el-icon-location-outline"></i> 籍贯 </template>
                  {{teacherBaseDetail.place}}
                </el-descriptions-item>
                <el-descriptions-item label="政治面貌">{{ teacherBaseDetail.polstatus }}
                </el-descriptions-item>
                <el-descriptions-item label="研究生导师">{{ teacherBaseDetail.tutor }}
                </el-descriptions-item>
                <el-descriptions-item label="教育背景">{{ teacherBaseDetail.education }}
                </el-descriptions-item>
                <el-descriptions-item label="婚姻状况">{{ teacherBaseDetail.marriage }}
                </el-descriptions-item>
                <el-descriptions-item label="入职时间">{{ teacherBaseDetail.entryTime }}
                </el-descriptions-item>
                <el-descriptions-item label="职称">{{ teacherBaseDetail.professionDrgree }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label">
                    <i class="el-icon-phone-outline"></i> 电话 </template>
                  {{teacherBaseDetail.tel}}
                </el-descriptions-item>
                <el-descriptions-item label="电子邮箱">{{ teacherBaseDetail.mail }}
                </el-descriptions-item>
                <el-descriptions-item label="人员状态">{{ teacherBaseDetail.status }}
                </el-descriptions-item>
                <el-descriptions-item label="密码">{{ teacherBaseDetail.password }}
                </el-descriptions-item>
              </el-descriptions>
            </div>
          </el-tab-pane>
          <el-tab-pane label="教师拓展信息">
            <el-tabs @tab-click="handleClick">
              <el-tab-pane label="教育背景" name="first">
                <div id="teacherDetailList" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :column="3" border>

                    <el-descriptions-item label="就读时间">{{ teacherBaseDetail.beginTime }}
                    </el-descriptions-item>

                    <el-descriptions-item label="毕业时间">{{ teacherBaseDetail.endTime }}
                    </el-descriptions-item>
                    <el-descriptions-item label="毕业院校">{{ teacherBaseDetail.graduationSchool }}
                    </el-descriptions-item>
                    <el-descriptions-item label="所修专业">{{ teacherBaseDetail.speciality }}
                    </el-descriptions-item>
                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="荣誉称号" name="second">
                <div id="teacherDetailList" v-for="mlist in Honor_titleList" :key="mlist.index" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`编号:${mlist.honorNO}`" :column="3" border>

                    <el-descriptions-item label="称号名称">{{ mlist.honorName }}
                    </el-descriptions-item>

                    <el-descriptions-item label="荣誉等级">{{ mlist.honorLevel }}
                    </el-descriptions-item>
                    <el-descriptions-item label="获取时间">{{ mlist.acquireTime }}
                    </el-descriptions-item>
                    <el-descriptions-item label="证书">{{ mlist.certificate }}
                    </el-descriptions-item>
                    <el-descriptions-item label="颁发部门">{{ mlist.Issuingdep }}
                    </el-descriptions-item>

                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="年度考核" name="third">
                <div id="teacherDetailList" v-for="mlist in Annual_examinationList" :key="mlist.index"
                  ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`编号:${mlist.checkNO}`" :column="3" border>

                    <el-descriptions-item label="考核项目">{{ mlist.checkName }}
                    </el-descriptions-item>

                    <el-descriptions-item label="考核结果">{{ mlist.checkResult }}
                    </el-descriptions-item>
                    <el-descriptions-item label="考核时间">{{ mlist.checkDate}}
                    </el-descriptions-item>
                    <el-descriptions-item label="考核年份">{{ mlist.checkYear }}
                    </el-descriptions-item>

                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="获奖情况" name="fourth">
                <div id="teacherDetailList" v-for="mlist in AwardList" :key="mlist.index" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`编号:${mlist.awardNO}`" :column="3" border>

                    <el-descriptions-item label="获奖时间">{{ mlist.awardTime }}
                    </el-descriptions-item>

                    <el-descriptions-item label="获奖名称">{{ mlist.awardName }}
                    </el-descriptions-item>
                    <el-descriptions-item label="授予单位">{{ mlist.awardIns }}
                    </el-descriptions-item>
                    <el-descriptions-item label="奖项级别">{{ mlist.awardLevel }}
                    </el-descriptions-item>
                    <el-descriptions-item label="获奖证书">{{ mlist.awardEnclosure }}
                    </el-descriptions-item>
                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="科研情况" name="fifth">
                <div id="teacherDetailList" ref="teacherDetailList">
                  <el-descriptions class="margin-top" v-for="mlist in Research_projectList" :key="mlist.index"
                    :title="`编号:${mlist.projectNO}`" :column="3" border>

                    <el-descriptions-item label="项目名">{{ mlist.projectName }}
                    </el-descriptions-item>

                    <el-descriptions-item label="项目经费">{{ mlist.projectFund }}
                    </el-descriptions-item>
                    <el-descriptions-item label="参与人员">{{ mlist.projectperson }}
                    </el-descriptions-item>
                    <el-descriptions-item label="科研方向">{{ mlist.projectDir }}
                    </el-descriptions-item>
                    <!-- <el-descriptions-item label="附件">{{ mlist.awardEnclosure }}
                    </el-descriptions-item> -->
                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="论文情况" name="sixth">
                <div id="teacherDetailList" v-for="m in thesislist" :key="m.thesisNo" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`论文名:${m.thesisName}`" :column="3" border>

                    <el-descriptions-item label="CN号">{{ m.thesisNO }}
                    </el-descriptions-item>

                    <el-descriptions-item label="论文名">{{ m.thesisName }}
                    </el-descriptions-item>
                    <el-descriptions-item label="发表时间">{{m.thesisDate }}
                    </el-descriptions-item>
                    <el-descriptions-item label="期刊类别">{{ m.thesisJour }}
                    </el-descriptions-item>
                    <el-descriptions-item label="论文类别">{{ m.category }}
                    </el-descriptions-item>
                    <el-descriptions-item label="第一作者">{{ m.thesisauthor }}
                    </el-descriptions-item>
                    <el-descriptions-item label="通讯作者">{{ m.thesisauthorTwo }}
                    </el-descriptions-item>
                    <el-descriptions-item label="附件">{{ m.thesisEnclosure }}
                    </el-descriptions-item>
                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="著作情况" name="seventh">
                <div id="teacherDetailList" v-for="mlist in OpusList" :key="mlist.index" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`ISCN号:${mlist.opusNO}`" :column="3" border>

                    <!-- <el-descriptions-item label="著作编号">{{ mlist.opusNO }}
                    </el-descriptions-item> -->

                    <el-descriptions-item label="著作名">{{ mlist.opusName }}
                    </el-descriptions-item>
                    <el-descriptions-item label="出版社">{{ mlist.publicer }}
                    </el-descriptions-item>
                    <el-descriptions-item label="著作类别">{{ mlist.opuscategory }}
                    </el-descriptions-item>
                    <el-descriptions-item label="著作级别">{{ mlist.opuslevel }}
                    </el-descriptions-item>
                    <el-descriptions-item label="参与人员">{{ mlist.opusperson }}
                    </el-descriptions-item>
                    <el-descriptions-item label="著作详情">{{ mlist.opusdetail }}
                    </el-descriptions-item>
                    <el-descriptions-item label="附件">{{ mlist.opusEnclosure }}
                    </el-descriptions-item>
                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="专利情况" name="eighth">
                <div id="teacherDetailList" v-for="mlist in PatentList" :key="mlist.patentNO" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`专利号:${mlist.patentNO}`" :column="3" border>

                    <!-- <el-descriptions-item label="专利号">{{ mlist.patentNO }}
                    </el-descriptions-item> -->

                    <el-descriptions-item label="专利名称">{{ mlist.patentName }}
                    </el-descriptions-item>

                    <el-descriptions-item label="专利等级">{{ mlist.patentlevel }}
                    </el-descriptions-item>
                    <el-descriptions-item label="专利类别">{{ mlist.patenttype }}
                    </el-descriptions-item>
                    <el-descriptions-item label="专利说明">{{ mlist.patentexplain }}
                    </el-descriptions-item>
                    <el-descriptions-item label="有效时间">{{ mlist.validtime }}
                    </el-descriptions-item>
                    <el-descriptions-item label="附件">{{ mlist.patentEnclosure }}
                    </el-descriptions-item>
                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="培训经历" name="ninth">
                <div id="teacherDetailList" v-for="mlist in TrainList" :key="mlist.index" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`${mlist.trainNO}`" :column="3" border>

                    <el-descriptions-item label="培训时间">{{ mlist.trainTime }}
                    </el-descriptions-item>

                    <el-descriptions-item label="培训地点">{{ mlist.trainadd }}
                    </el-descriptions-item>

                    <el-descriptions-item label="培训课题">{{ mlist.traintit }}
                    </el-descriptions-item>
                    <el-descriptions-item label="培训用书">{{ mlist.trainbook }}
                    </el-descriptions-item>
                    <el-descriptions-item label="培训单位">{{ mlist.trainposition }}
                    </el-descriptions-item>
                    <el-descriptions-item label="附件">{{ mlist.trainEnclosure }}
                    </el-descriptions-item>

                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="研究生导师"  v-if="teacherBaseDetail.tutor =='是'"  name="tenth">
                <div id="teacherDetailList" ref="teacherDetailList">
                  <el-descriptions class="margin-top" title="具体信息" :column="3" border>

                    <el-descriptions-item label="研究课题">{{ teacherBaseDetail.tutortitle }}
                    </el-descriptions-item>

                    <el-descriptions-item label="所属专业系">{{ teacherBaseDetail.specialize }}
                    </el-descriptions-item>

                    <el-descriptions-item label="研究方向">{{ teacherBaseDetail.researchdir }}
                    </el-descriptions-item>
                    <el-descriptions-item label="所带学生数">{{ teacherBaseDetail.stuNum }}
                    </el-descriptions-item>
                    <el-descriptions-item label="学位">{{ teacherBaseDetail.degree }}
                    </el-descriptions-item>
                    <el-descriptions-item label="邮箱">{{ teacherBaseDetail.email }}
                    </el-descriptions-item>

                  </el-descriptions>
                </div>
              </el-tab-pane>

              <el-tab-pane label="工作经历" name="elevant">
                <div id="teacherDetailList" v-for="mlist in WorkList" :key="mlist.index" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`${mlist.workadd}`" :column="3" border>

                    <el-descriptions-item label="就职日期">{{ mlist.intime }}
                    </el-descriptions-item>

                    <el-descriptions-item label="离职日期">{{ mlist.outtime }}
                    </el-descriptions-item>

                    <el-descriptions-item label="工作地点">{{ mlist.workadd }}
                    </el-descriptions-item>
                    <el-descriptions-item label="工作职位">{{ mlist.workposition }}
                    </el-descriptions-item>
                    <el-descriptions-item label="工作内容">{{ mlist.workcontent }}
                    </el-descriptions-item>
                    <el-descriptions-item label="附件">{{ mlist.trainEnclosure }}
                    </el-descriptions-item>

                  </el-descriptions>
                </div>
              </el-tab-pane>
              <el-tab-pane label="教学工作" name="tewfw">
                <div id="teacherDetailList" v-for="mlist in Teach_workList" :key="mlist.index" ref="teacherDetailList">
                  <el-descriptions class="margin-top" :title="`学院:${mlist.faculty}`" :column="3" border>

                    <el-descriptions-item label="学期">{{ mlist.term }}
                    </el-descriptions-item>

                    <!-- <el-descriptions-item label="学院">{{ mlist.faculty }}
                    </el-descriptions-item> -->

                    <el-descriptions-item label="课程名称">{{ mlist.courseName }}
                    </el-descriptions-item>
                    <el-descriptions-item label="授课班级">{{ mlist.Classname }}
                    </el-descriptions-item>
                    <el-descriptions-item label="授课时数">{{ mlist.teachHour }}
                    </el-descriptions-item>
                    <el-descriptions-item label="课程学分">{{ mlist.credit }}
                    </el-descriptions-item>

                  </el-descriptions>
                </div>
              </el-tab-pane>
            </el-tabs>
          </el-tab-pane>
        </el-tabs>
      </el-dialog>
      <!--分页工具条-->
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]" :page-size="5" layout="total, sizes, prev, pager, next, jumper"
        :total="totalCount ">
      </el-pagination>
    </el-main>
  </el-container>
</template>

<script>
import axios from "axios";
export default {
name:"Colteacher",
data(){
return {
  // 接受学院的信息
  academyName: '',
  // 搜索表单的数据
  searchBase: {
    teacherid: "",
    teacherName: "",
     status:"",
  },
  //在校状态
  options: [{
    value: '在岗',
    label: '在岗'
  }, {
    value: '不在岗',
    label: '不在岗'
  },{
    value:"",
    label:'无'
  }],
  value:"",
  // 教师的信息
  teacherinfo:[],
  // 导出EXCEL的页面数据
  json_fields: {
     "教师号":"teacherid",
     "姓名":"teacherName",
     "性别":"sex",
     "籍贯":"place",
     "出生日期":"birth",
     "身份证号":"numberID",
     "民族":"nation",
    
    "政治面貌":"polstatus",
    "入职时间":"entryTime",
    "电话":"tel",
    "电子邮箱":"mail",
    "婚姻状况":"marriage",
    "学历":"education",
    "研究生导师":"tutor",
    "职称":"title",
  },
  //详情界面
  dialogDetail: false,
  teacherBaseDetail: {},
  // 修改页面
  dialogUpdate:false,
  teacherUpdate:{ },
  //表单检验的简单规则
  changeTeacherRules: {
    teacherName: [
      { required: true, message: '请输入姓名', trigger: 'blur' },
    ],
    sex: [{ required: true, message: '请选择您的性别', trigger: 'change' }],
    birth: [{ type: 'date', required: true, message: '请选择日期', trigger: 'change' },],
    place: [
      { required: true, message: '请输入详细地址', trigger: 'blur' },
      { pattern: /^[^\s]*$/, message: '不能含有空格', trigger: 'change' }
    ],
    numberId: [
      { required: true, message: '请输入您的身份证号', trigger: 'blur' },
      {
        validator: (rule, value, callback) => {
          if (value.length !== 18) {
            callback(new Error('请正确输入身份证号'))
          } else {
            callback();
          }
        }
      },
      { pattern: /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/, message: '请正确书写身份证号码', trigger: 'change' }
    ],
    nation: [
      { required: true, message: '请输入民族', trigger: 'blur' },
    ],
    status: [
      { required: true, message: '请输入人员状态', trigger: 'blur' },
    ],
    academyName: [
      { required: true, message: '请输入所在学院', trigger: 'blur' },
      { pattern: /^[^\s]*$/, message: '不能含有空格', trigger: 'change' }
    ],
    //需要查询部门是否存在
    departmentName: [
      { required: true, message: '请输入所在部门', trigger: 'blur' },
    ],
    polstatus: [
      //需要查询学院是否存在
      { required: true, message: '请输入所在学院', trigger: 'blur' },
    ],
    entryTime: [{ type: 'date', required: true, message: '请选择日期', trigger: 'change' }],
    tel: [
      { required: true, message: '请输入您的手机号码', trigger: 'blur' },
      {
        validator: (rule, value, callback) => {
          if (value.length !== 11) {
            callback(new Error('请输入11位手机号码呀'))
          } else {
            callback()
          }
        }
      }
    ],
    mail: [
      { pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, type: 'email', required: true, message: '请输入正确的邮箱', trigger: 'blur' },
    ],
    marriage: "",
    education: [
      { required: true, message: '请输入学历', trigger: 'blur' },
    ],
    tutor: [],
    professionDrgree: [],
    password: [{ pattern: /^\w{6,18}$/, message: '密码由6~18位字母、数字和下划线组成', trigger: 'change' },]
  },
  nationOptions: [{
    value: '汉族',
    label: '汉族'
  }, {
    value: '蒙古族',
    label: '蒙古族'
  }, {
    value: '回族',
    label: '回族'
  }],
  // 是否是研究生导师
  radio: '1',
  //选择的地区  籍贯
  regionOptions: '',
  handleChangeRegion:'',
  activeName:'first',
  // 分页的属性
  totalCount: 0,
  pageSize: 5,
  totalCount: 0,
  // 获取后端的论文数据
  thesislist:[],
  Research_projectList:[],
  Annual_examinationList:[],
  AwardList:[],
  Honor_titleList:[],
  OpusList:[],
  Teach_workList:[],
  TrainList:[],
  PatentList:[],
  WorkList:[],
  //被选中的id
  selectedIds: [],
  // 当前页码
  currentPage: 1,
}
  },mounted() {
    this.academyName = this.$route.query.mark
    this.selectinfo();
   
  },
methods:{
   getThesis(id){
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getThesisList?id=" + id,
    }).then(resp => {
      this.thesislist = resp.data;
    })
   },
  getResearch_project(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getResearch_project?id=" + id,
    }).then(resp => {
      this.Research_projectList = resp.data;
    })
  },
  getAnnual_examination(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getAnnual_examination?id=" + id,
    }).then(resp => {
      this.Annual_examinationList = resp.data;
    })
  },
  getAward(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getAward?id=" + id,
    }).then(resp => {
      this.AwardList = resp.data;
    })
  },
  getHonor_title(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getHonor_title?id=" + id,
    }).then(resp => {
      this.Honor_titleList = resp.data;
    })
  },
  getOpus(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getOpus?id=" + id,
    }).then(resp => {
      this.OpusList = resp.data;
    })
  },
  getTeach_work(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getTeach_work?id=" + id,
    }).then(resp => {
      this.Teach_workList = resp.data;
    })
  },
  getTrain(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getTrain?id=" + id,
    }).then(resp => {
      this.TrainList = resp.data;
    })
  },
  getPatent(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getPatent?id=" + id,
    }).then(resp => {
      this.PatentList = resp.data;
    })
  },
  getWork(id) {
    axios({
      method: "get",
      url: " http://localhost:8888/Teachersystem/Teacher/getWork?id=" + id,
    }).then(resp => {
      this.WorkList = resp.data;
    })
  },
  selectinfo(){
    // 获取后端需要审核的数据
   
    axios({
      method:"post",
      url: " http://localhost:8888/Teachersystem/Teacher/selectByPageAndCondition?currentPage=" + this.currentPage + "&pageSize=" + this.pageSize + "&academyName=" + this.academyName,
      data:this.searchBase
    }).then(resp => {
      this.teacherinfo = resp.data.rows;
      this.totalCount = resp.data.totalCount;
    })
  },
  // 提交查询
  onSubmit() {
    this.searchBase.status = this.value
   this.selectinfo();
  },

  // 复选框选中后执行的方法
  handleSelectionChange(val) {
    this.multipleSelection = val;
  
    for (let i = 0; i < this.multipleSelection.length; i++) {
      this.selectedIds[i] = this.multipleSelection[i].id;
    }
  },

  //根据身份证号书写出生日期
  changeBirth() {
    let time = this.teacherBaseDetail.numberId;
    this.teacherBaseDetail.birth = time.substring(6, 10) + "-" + time.substring(10, 12) + "-" + time.substring(12, 14);
  },
//根据ID删除
  deleteById(row) {
    this.$confirm('此操作删除该教师, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
     
      axios({
        method: "get",
        url: " http://localhost:8888/Teachersystem/Teacher/delteacher?id=" + row.teacherid,
      }).then(resp =>{
        if (resp.data === "ok") {
          this.$message({
            message: '恭喜你，删除成功',
            type: 'success'
          });
        }
        this.selectinfo();
      })
    }).catch(() => {
      this.$message({
        type: 'info',
        message: '已取消删除'
      });
    });
  },
  // 显示修改界面
  showUpdate(row) {
    this.dialogUpdate = true;
    this.teacherUpdate=row;
   
  },
  //显示教师详细信息界面
  showTeacherDetail(row) {
    this.dialogDetail = true;
    this.teacherBaseDetail = row;
    this.getThesis(row.teacherid);
    this.getResearch_project(row.teacherid);
    this.getAnnual_examination(row.teacherid);
    this.getAward(row.teacherid);
    this.getHonor_title(row.teacherid);
    this.getOpus(row.teacherid);
    this.getTeach_work(row.teacherid);
    this.getTrain(row.teacherid);
    this.getPatent(row.teacherid);
    this.getWork(row.teacherid);

  },
  
  handleClick(tab, event) {
    console.log(tab, event);
  },
  //保存教师基本信息
  saveTeacherDetail() {
    this.$confirm('此操作将修改教师信息, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'success'
    }).then(() => {
      axios({
        method: "post",
        url: " http://localhost:8888/Teachersystem/Teacher/UpdateTeacher",
        data: this.teacherUpdate
      }).then(resp => {
        if(resp.data=="ok"){
           this.$message({
        type: 'success',
        message: '修改成功!'
      });
      this.dialogUpdate = false;
    
        }
      })
    }).catch(() => {
      this.$message({
        type: 'info',
        message: '已取消修改'
      });
    });
  },
  //分页
  handleSizeChange(val) {
    // console.log(`每页 ${val} 条`);
    this.pageSize = val;
    this.selectinfo();
  },
  handleCurrentChange(val) {
    // console.log(`当前页: ${val}`);
    this.currentPage = val;
    this.selectinfo();
  }
},

}
</script>

<style>


</style>